﻿using Ajr.DigitaPlatform.DataAccess;
using Ajr.DigitaPlatform.IDataAccess;
using Ajr.DigitaPlatform.ViewModels;
using CommonServiceLocator;
using GalaSoft.MvvmLight.Ioc;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ajr.DigitaPlaform.ViewModels
{
    public class ViewModelLocator
    {
        public ViewModelLocator()
        {
            //保证ioc全局独立性
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
            SimpleIoc.Default.Register<LoginViewModel>();
            SimpleIoc.Default.Register<MainViewModel>();
            SimpleIoc.Default.Register<ConfigViewModel>();

            SimpleIoc.Default.Register<ILocalDataAccess, LocalDataAccess>();



        }
        //定义方式有歧义
        public LoginViewModel LoginViewModel => ServiceLocator.Current.GetInstance<LoginViewModel>();
        //public string value { get {return ServiceLocator.Current.GetInstance<LoginViewModel>()  }
        public MainViewModel MainViewModel => ServiceLocator.Current.GetInstance<MainViewModel>();
        public ConfigViewModel ConfigViewModel => ServiceLocator.Current.GetInstance<ConfigViewModel>();



        public void Cleanup()
        {
            //MainViewModel.Release();
        }
    }
}